//
//  NSUserDefaults+Addition.m
//  dzmmac
//
//  Created by admin on 14-4-8.
//  Copyright (c) 2014年 wt. All rights reserved.
//

#import "NSUserDefaults+Addition.h"
#import "AppConfig.h"
@implementation NSUserDefaults (Addition)

#define sys_version   [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]


NSString *const APPDefaultsKeyMemberId=@"app_memberId";
NSString *const APPDefaultsKeyUserCity=@"UserCity";
NSString *const APPDefaultsKeyUserCityId=@"UserCityId";

/**
 *  会员ID
 *
 *  @return 会员ID
 */
- (NSString *)app_memberId {
    return [self stringForKey:APPDefaultsKeyMemberId];
}

/**
 *  会员ID
 *
 *  @return 会员ID
 */
- (void)app_setMemberId:(NSString *)app_memberId {
    [self setObject:app_memberId forKey:APPDefaultsKeyMemberId];
}

- (BOOL)app_launched {
    return [[self objectForKey:sys_version] boolValue];
}

- (void)app_setLaunched:(BOOL)app_launched{
    [self setObject:[NSNumber numberWithBool:app_launched] forKey:sys_version];
}

/**
 *  用户上次选择的城市
 */
-(NSString *)getUserSelectedCity
{
    return [[self objectForKey:APPDefaultsKeyUserCity] stringByReplacingOccurrencesOfString:@"市" withString:@""];
}

/**
 *  用户选择的城市
 */
-(void)setUserSelectedCity:(NSString *)userSelectedCity
{
    userSelectedCity =  [userSelectedCity  stringByReplacingOccurrencesOfString:@"市" withString:@""];
    [self setObject:userSelectedCity forKey:APPDefaultsKeyUserCity];
}

/**
 *  用户上次选择的城市
 */
-(NSString *)getUserSelectedCityID
{
    return [self objectForKey:APPDefaultsKeyUserCityId];
}


/**
 *  用户选择的城市
 */
-(void)setUserSelectedCityID:(NSString *)userSelectedCityID
{
    if (userSelectedCityID == nil) {
        return;
    }
    [self setObject:userSelectedCityID forKey:APPDefaultsKeyUserCityId];
}

@end
